package generic;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

// ？
public class Tongpeifu {
    public static void main(String[] args) {
        List<Object> list1 = new ArrayList<>();
        list1.add(1);
        list1.add("kk");
        List<String> list2 = new ArrayList<>();
        list2.add("kk");
        list2.add("wy");

        List<?> list=null;
        list=list1;
//        list.add("ll");
        Object o = list.get(0);
//        print(list1);
//        print(list2);
    }
    public static void print(List<?> list){
        Iterator<?> iterator = list.iterator();
        while(iterator.hasNext()){
            Object obj = iterator.next();
            System.out.println(obj);
        }
    }


}

class two{
    class Animal{}
    class Dog extends Animal{}
    static void countLegs (List<? extends Animal > animals ) {
    }

    static void countLegs1 (List< Animal > animals ){
    }

    public static void main(String[] args) {
        List<Dog> dogs = new ArrayList<>();
        // 不会报错
        countLegs( dogs );
        // 报错
//        countLegs1(dogs);
    }
}